﻿namespace Cil.Ast
{
    public sealed class SwitchIndexExpression : Expression
    {
        public const int IndexPos = 0;
        public const int MaxNodes = 1;

        public SwitchIndexExpression(Context context, Expression index)
            : base(context)
        {
            // base class
            ReturnType = Context.MakeRef(typeof(void));
            WritesStack = 0;
            ReadsStack = 0;
            Nodes = new FixedList<Expression>(MaxNodes);

            // this
            Index = index;
        }

        public Expression Index
        {
            get => Nodes[IndexPos];
            set
            {
                Nodes[IndexPos] = value;
                value.ParentNode = this;
            }
        }

        public override string ToString()
        {
            return Index.ToString();
        }
    }
}